package com.yan.springcloud;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * @author ：Yan Guang
 * @date ：Created in 2020/11/28 17:23
 * @description：
 */
@SpringBootApplication
@MapperScan("com.yan.springcloud.mapper")
@EnableEurekaClient//在服务启动后，自动注册到eureka中
@EnableDiscoveryClient//服务发现,主要是用来看服务的信息
@EnableCircuitBreaker//添加对熔断的支撑
public class DeptProvider_hystrix8002 {
    public static void main(String[] args) {
        SpringApplication.run(DeptProvider_hystrix8002.class, args);
    }

    //增加一个Servlet
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registrationBean.addUrlMappings("/actuator/hystrix.stream");
        return registrationBean;
    }
}
